package com.lhb.controller;

import com.lhb.pojo.BaseResp;
import com.lhb.pojo.Comment;
import com.lhb.pojo.Course;
import com.lhb.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.10.14 下午 22:51
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    @RequestMapping("/findAll")
    public BaseResp findAll(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit) {
        return commentService.findAll(page, limit);
    }

    //删除
    @RequestMapping(value = "del", method = RequestMethod.GET)
    public BaseResp delete(@RequestParam("id") Integer id) {
        commentService.del(id);
        BaseResp baseResp = new BaseResp();
        baseResp.setCode(1);
        baseResp.setMsg("删除成功");
        return baseResp;
    }

    @RequestMapping("/update")
    public BaseResp update(@RequestBody Comment comment) {
        return commentService.updateComment(comment);
    }

    @RequestMapping("/Add")
    public BaseResp AddComment(@RequestBody Comment comment) {
        return commentService.AddComment(comment);
    }
}
